import 'package:flutter/material.dart';
import 'package:flutter_basic/pages/order_detail.dart';

class OrderList extends StatelessWidget {
  const OrderList({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('订单列表页'),
        centerTitle: true,
      ),
      body: Container(
          width: 200,
          height: 300,
          color: Colors.black26,
          child: Column(
            children: [
              GestureDetector(
                onTap: () {
                  // 1. 第一种路由方式
                  // 跳转到订单详情页
                  // Navigator.push(
                  //   context,
                  //   MaterialPageRoute(
                  //     builder: (BuildContext context) {
                  //       return const OrderDetail();
                  //     },
                  //   ),
                  // );

                  // 2. 第二种路由方式
                  Navigator.pushNamed(context, '/detail');
                },
                child: Image.network(
                    'https://yanxuan-item.nosdn.127.net/e529b6ab111ade9da9314867f98d360f.png'),
              ),
              FilledButton(
                onPressed: () {
                  // 第二种路由方式
                  Navigator.pushNamed(context, '/detail');
                },
                child: const Text('去详情页-路径变了（推荐）'),
              ),
              TextButton(
                onPressed: () {
                  // 跳转到订单详情页
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (BuildContext context) {
                        return const OrderDetail();
                      },
                    ),
                  );
                },
                child: const Text('去详情页-路径没变'),
              ),
            ],
          )),
    );
  }
}
